package com.atlzk.group.payment.controller;

import com.alipay.api.AlipayApiException;
import com.atlzk.group.payment.utils.AlipayTemplate;
import com.atlzk.group.payment.vo.PayVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author King
 * @date 2021/6/20 - 15:14
 */
@RestController
@RequestMapping("/pay")
public class PayController {

    @Autowired
    private AlipayTemplate alipaayTemplate;

    @PostMapping("/pay")
    public String pay(@RequestBody PayVo payVo) {
        System.out.println(payVo);
        try {
            return alipaayTemplate.pay(payVo);
        } catch (AlipayApiException e) {
            e.printStackTrace();
        }
        return null;
    }

}
